home *** CD-ROM | disk | FTP | other *** search
- Path: news.magmacom.com!not-for-mail
- From: ezust@mag1.magmacom.com (Acme Instant Dehydrated Boulder Kit)
- Newsgroups: comp.lang.c++
- Subject: Re: delete or delete [] ?
- Date: 4 Apr 1996 13:44:51 -0500
- Organization: Cloud-Zero, Canada
- Message-ID: <4k15b3$f83@mag1.magmacom.com>
- References: <4jpe5j$3vo@doc.zippo.com> <4ju30g$96q@cloner2.ix.netcom.com>
- NNTP-Posting-Host: mag1.magmacom.com
-
- In article <4ju30g$96q@cloner2.ix.netcom.com>,
- John Lilley <jlilley@ix.netcom.com> wrote:
- >
- >Please be careful giving advice on this! The operators delete and delete[] need not
- >be implemented identically, especially since in the ANSI draft (and I believe the
- >ARM?) one can override one operator pair (new/delete or new[]/delete[]) without the
- >overriding the other. In addition, some implementations of new[]/delete[] allocate
- >data preceding the returned memory pointer to keep track of the number and size of
- >the objects in the array.
- >
- >The rule is: if you allocate with new[], then free with delete[].
- >In your example, I believe that operator new[] is called for allocation,
- >since the type is an array, so call operator delete[] to free it.
- >
-
- in the example, he was NOT allocating with new[]. The typedef was like this
-
- typedef int int10[10];
-
- int* ip = new int10;
-
- No new[] operator used here. So by that logic he shouldn't be using
- delete[].
-
- --
- Alan Ezust "Just because I work for the federal
- Ottawa, Canada government doesn't mean I'm an expert
- ezust@magmacom.com on cockroaches" -Special Agent Fox Mulder
- http://www2.magmacom.com/~ezust
-